package fate;


import java.util.zip.DataFormatException;
import java.util.zip.Inflater;

public class ZlibUtils {

    public static byte[] uncompress(byte[] buffer, int original_size) throws DataFormatException {
        Inflater decompresser = new Inflater();
        decompresser.setInput(buffer);
        byte[] output = new byte[(int) original_size];
        int n = decompresser.inflate(output);
        if (n != original_size) {
            throw new RuntimeException("Incorrect uncompressed size");
        }
        decompresser.end();
        return output;
    }
}
